Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to a helper and fix tests #648

Merged
merged 2 commits into from
Aug 15, 2017
Merged

Move to a helper and fix tests #648

merged 2 commits into from
Aug 15, 2017

Conversation

gauravtiwari
Copy link
Member

@gauravtiwari gauravtiwari commented Aug 13, 2017

Moves the reloaded_config method to a helper and use that for dev_server_test as well

gauravtiwari referenced this pull request Aug 13, 2017
Then Webpacker.dev_server.running? will return false in testing even though the dev server is running, so on-demand testing will work as expected.
@javan
Copy link
Contributor

javan commented Aug 14, 2017

How about creating a base test class instead?

# webpacker_test_helper.rb

class Webpacker::Test < Minitest::Test
  private
    def reloaded_config
      Webpacker.instance.instance_variable_set(:@config, nil)
      Webpacker.config
    end

    def with_node_env(env)
      original = ENV["NODE_ENV"]
      ENV["NODE_ENV"] = env
      yield
    ensure
      ENV["NODE_ENV"] = original
    end
end

@gauravtiwari
Copy link
Member Author

@javan Even better 👍 💯 Pushed an update

@gauravtiwari gauravtiwari merged commit cef39c8 into master Aug 15, 2017
@gauravtiwari gauravtiwari deleted the fix-tests branch August 15, 2017 17:14
gauravtiwari added a commit that referenced this pull request Aug 15, 2017
* master:
  Move to a helper and fix tests (#648)
  Spacing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants